(function($, undefined) {
	$.fn.mallAudit = function(options) {
		var settings = {
			fid : 0
		};
		if (options) {
			$.extend(settings, options);
		}
		var size = 0;
		var obj = this;
		var setDoAudit = function() {
			$("a.doAudit").click(function() {
				var tid = $(this).attr("tid");
				$.getJSON(setting.url + "/doAudit/tid/" + tid, function(data) {
					if (data.status == 1) {
						$("div#task_" + tid).hide("normal");
						// 判断是否还有数据没有继续加载
						size--;
						if (size < 1) {
							getTasks();
						}
					} else {
						alert(data.data);
					}
				});
			});
		}
		var getTasks = function() {
			$.getJSON(setting.url + "/auditList/", function(data) {
				if (data.status == 1) {
					size = data.info;
					$(obj).html(data.data);
					setDoAudit();
				} else {
					alert(data.data);
				}
			});
		};
		$("#taskRefresh").click(function() {
			getTasks();
		});
		getTasks();
	};
}(jQuery));